import { ColumnGroupType, ColumnType } from "antd/es/table"

import { IResponseItem } from "@/api/funds/agentWithdrawalReview/types"

const AgentWithdrawalReviewColumns = (
	newFormat: (arg: string) => string,
	renderCopyNo: (arg: string) => any,
	getLabel: (value: string | number, modal: string, strictlyLabel?: boolean, customDictArr?: any[]) => any
): Record<string, ColumnGroupType<any> | ColumnType<any>> => {
	const getAuditStatusClass = (rowData: any) => {
		let className = "normalRgba"
		if (rowData.auditStatus === 11) {
			className = "deleteRgba"
		} else if (rowData.auditStatus === 13) {
			className = "failRgba"
		} else if (rowData.auditStatus === 12) {
			className = "rejectRgba"
		} else if (rowData.auditStatus === 7) {
			// 待出款
		} else if (Number(rowData.lockStatus) === 1) {
			className = "lockingRgba"
		}
		return className
	}

	const fundsWithdrawalReview_userName: ColumnType<IResponseItem> = {
		title: newFormat("funds.proxy_name"),
		dataIndex: "userName",
		key: "userName",
		align: "center",
		width: 150,
		render: renderCopyNo
	}

	const fundsWithdrawalReview_bigWithdraw: ColumnType<IResponseItem> = {
		title: newFormat("funds.fund_audit.big_withdraw"),
		dataIndex: "bigWithdraw",
		key: "bigWithdraw",
		align: "center",
		width: 150,
		render: (text: string) => (
			<span style={{ color: Number(text) === 1 ? "red" : "" }}>
				{Number(text) === 1 ? newFormat("common.yes") : newFormat("common.no")}
			</span>
		)
	}

	const fundsWithdrawalReview_payType: ColumnType<IResponseItem> = {
		title: newFormat("funds.pay_type"),
		dataIndex: "payType",
		key: "payType",
		align: "center",
		width: 130,
		render: (_: string, record: any) =>
			Number(record.withdrawType) === 1
				? newFormat("funds.proxy_member_funds_record.brank_card")
				: newFormat("funds.proxy_member_funds_record.virtual_currency") || "-"
	}

	const fundsWithdrawalReview_auditStatus: ColumnType<IResponseItem> = {
		title: newFormat("funds.fund_audit.audit_status"),
		dataIndex: "auditStatus",
		key: "auditStatus",
		align: "center",
		width: 150,
		render: (text: string, record: any) => (
			<span className={getAuditStatusClass(record)}>{getLabel(text, "auditStatus", false)}</span>
		)
	}

	const agentTopupReview_lockStatus: ColumnType<any> = {
		title: newFormat("funds.fund_audit.audit_status"),
		dataIndex: "lockStatus",
		key: "lockStatus",
		align: "center",
		width: 150,
		render: (text: string, record: any) => (
			<span className={Number(record.lockStatus) === 1 ? "lockingRgba" : "deleteRgba"}>
				{getLabel(text, "auditStatus", false)}
			</span>
		)
	}

	const fundsWithdrawalReview_lockTime: ColumnType<IResponseItem> = {
		title: newFormat("funds.fund_audit.lock_time"),
		dataIndex: "lockTime",
		key: "lockTime",
		align: "center",
		width: 220,
		render: (text: string) => text || "-"
	}

	const fundsWithdrawalReview_lockAccount: ColumnType<IResponseItem> = {
		title: newFormat("funds.fund_audit.lock_account"),
		dataIndex: "lockAccount",
		key: "lockAccount",
		align: "center",
		width: 220,
		render: (text: string) => text || "-"
	}

	const fundsWithdrawalReview_thirdOrderStatus: ColumnType<IResponseItem> = {
		title: newFormat("funds.fund_audit.third_withdraw_status"),
		dataIndex: "thirdOrderStatus",
		key: "thirdOrderStatus",
		align: "center",
		width: 120,
		render: (text: number) => (
			<span>{text === 0 ? "出款成功" : text === 1 ? "出款失败" : text === 2 ? "未知" : text === 3 ? "处理中" : "-"}</span>
		)
	}

	return {
		fundsWithdrawalReview_userName,
		fundsWithdrawalReview_bigWithdraw,
		fundsWithdrawalReview_payType,
		fundsWithdrawalReview_auditStatus,
		fundsWithdrawalReview_lockTime,
		fundsWithdrawalReview_lockAccount,
		fundsWithdrawalReview_thirdOrderStatus,

		agentTopupReview_lockStatus
	}
}

export default AgentWithdrawalReviewColumns
